{
    var director_item=document.getElementsByClassName('director_item');
    var temp=0;
    var cn1=0;
    var cn2=0;
    var cn3=true;
    var wrapper=document.getElementsByClassName('wrapper');
    var banner_item=document.getElementsByClassName('banner_item');
    var tb_wrapper1=document.getElementsByClassName('tb_wrapper1');
    var tb_wrapper2=document.getElementsByClassName('tb_wrapper2');
    var user1,user2,user3,user4;//请假用户对象数组、调研学用户对象数组
    var avatar=document.getElementById('avatar');
    var user_event=document.getElementById('user_event');
    var whole_wrapper=document.getElementById('whole_wrapper');
    var banner_hidden=document.getElementsByClassName('banner_hidden');
    var banner_table=document.getElementsByClassName('banner_table');
}

//本周请假
function draw_table2(info,i,user){
    info.insertAdjacentHTML('beforeend',`<tr>
                <td><div class="table_box1">${user[i].name}</div></td>
                <td><div class="table_box1">${user[i].direction}</div></td>
                <td><div class="table_box1">${user[i].term}</div></td>
                <td><div class="table_box3">
                        <div class="table_box3_child1">${user[i].leave_date}</div>
                        <div class="table_box3_child2">第${user[i].leave_class}节</div>
                    </div></td>
                <td><div class="table_box2">${user[i].reason}</div></td>
                </tr>`);
}

//本周调整
function draw_table4(info,i,user){
    info.insertAdjacentHTML('beforeend',`<tr>
                <td><div class="table_box1">${user[i].name}</div></td>
                <td><div class="table_box1">${user[i].direction}</div></td>
                <td><div class="table_box1">${user[i].term}</div></td>
                <td><div class="table_box3">
                        <div class="table_box3_child1">${user[i].leave_date}</div>
                        <div class="table_box3_child2">第${user[i].leave_class}节</div>
                    </div></td>
                <td><div class="table_box3">
                        <div class="table_box3_child1">${user[i].adjust_date}</div>
                        <div class="table_box3_child2">第${user[i].adjust_class}节</div>
                    </div></td>
                <td><div class="table_box2">${user[i].reason}</div></td>
                </tr>`);
}
function rmtb(obj){
    if(obj.length!==0){
        for(let i=0;i<obj.length;i++){
            let li=obj[0].getElementsByTagName('tbody');
            while(li.length!==0){
                li[0].remove();
            }
        }
    }
}

//获取数据 渲染数据
axios({
    method:"post",
    url:"http://frp-fly.top:54242/SLS/LeaveRecordServlet",
    headers:{
        "Content-type":"application/json"
    }
}).then(response=>{
    console.log(response);
    user1=response.data.data;
    if(response.data.code=="0001"){
        banner_hidden[0].style.display = 'block'
        banner_table[0].style.display = 'none'
    }
    else{
        for(let i=0;i<user1.length;i++){
            let info=tb_wrapper1[0].getElementsByTagName('table');
            draw_table2(info[0],i,user1);
        }
    }
    
})
axios({
    method:"post",
    url:"http://jp-tyo-ntt-1.natfrp.cloud:50928/Study_Leave_System_war_exploded/AdjustRecordServlet",
    headers:{
        "Content-type":"application/json"
    }
}).then(response=>{
    console.log(response.data.code);
    user2=response.data.data;
    if(response.data.code==0001){
        banner_hidden[1].style.display = 'block'
        banner_table[1].style.display = 'none'
    }
    else{
        for(let i=0;i<user2.length;i++){
            let info=tb_wrapper1[0].getElementsByTagName('table');
            draw_table4(info[0],i,user2);
        }
    }
})

avatar.onclick=function(){
    if(cn3){
        user_event.style.display='block';
        cn3=false;
    }else{
        user_event.style.display='none';
        cn3=true;
    }
};
user_event.onclick=()=>{
    window.location="./test.html";
};


user3=user1;
user4=user2;

